﻿using System;
using System.IO;

namespace Path_Sample {
    class Program {
        static void Main(string[] args) {
            Console.Write("Insert the first path: ");
            //string path1 = "c:\\temp\\other";
            string path1 = Console.ReadLine();
            Console.Write("Insert the second path: ");
            //string path2 = "..\\subdir\\file.txt";
            string path2 = Console.ReadLine();
            combinePaths(path1, path2);
            Console.ReadKey();
        }

        private static void combinePaths(string path1, string path2) {
            try {
                string combination = Path.GetFullPath(Path.Combine(path1, path2));

                Console.WriteLine("When you combine '{0}' and '{1}', the result is: {2}'{3}'",
                            path1, path2, Environment.NewLine, combination);
            } catch (Exception e) {
                if (path1 == null) { 
                    path1 = "null"; 
                }
                if (path2 == null) {
                    path2 = "null"; 
                }                
                Console.WriteLine("You cannot combine '{0}' and '{1}' because: {2}{3}",
                            path1, path2, Environment.NewLine, e.Message);
            }
            Console.WriteLine();
        }
    }
}